package a66weding.com.jiehuntong.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/6/3.
 */
public class DateModel {

    /**
     * 所有年
     */
    public String[] mProvinceDatas;
    /**
     * 所有月
     */
    public String [] mMonth=new String[12];
    /**
     * 所有日
     */
    String [] mDay=null;

    List<Map<String,String[]>> dateList=new ArrayList<>();
    
    
    /**
     * key - 年 value - 月
     */
    protected Map<String, String[]> mCitisDatasMap = new HashMap<String, String[]>();
    /**
     * key - 月 values - 日
     */
    public Map<String, String[]> mDistrictDatasMap = new HashMap<String, String[]>();

    
    public void getData(){

        mProvinceDatas=new String[230];
        List<String> mYearList=new ArrayList<String>();



        for (int i = 0; i < mProvinceDatas.length; i++) {
            mProvinceDatas[i]=1970+i+"年";
            mYearList.add(mProvinceDatas[i]);
        }


        // mDistrictDatasMap

        for (int i = 0; i < mYearList.size(); i++) {

            mCitisDatasMap.put(mYearList.get(i),mMonth);

            for (int j = 0; j < mMonth.length; j++) {

                mMonth[j]=j+1+"月";

               if(j+1==2) {//2月
                  if(isLeapYear(Integer.valueOf(mYearList.get(i)))) {
                      mDay=new String[29];
                  } else{
                      mDay=new String[28];
                  }
               }else if(j+1==1|| j+1==3 || j+1==5 ||j+1==7 || j+1==8 || j+1==10 || j+1==12){//30天月
                   mDay=new String[30];
                   handleDay(mDay);

               }else{//31天月
                   mDay=new String[31];
                   handleDay(mDay);
               }

                mDistrictDatasMap.put(mMonth[j],mDay);

            }
            dateList.add(mDistrictDatasMap);
        }
    }

    public List<Map<String, String[]>> getDateList() {
        return dateList;
    }

    public void handleDay(String [] dayArray){

        for (int i = 0; i < dayArray.length; i++) {
            dayArray[i] = i + 1 + "日";
        }

    }

    public static boolean isLeapYear(int year) {
        boolean flag=false;
        if((year%4 == 0) && ((year%100 != 0) || (year%400 == 0))){
            flag=true;
        }
        return flag;
    }

}
